***********************************************************************************
// STEP 1: RUN TO SET DIRECTORY
***********************************************************************************
// Run these lines first to set the path before running the rest of the do file:
ssc install project
// Find and select this Master.do when you are prompted to browse for the file: 
project, setup
project Master, cd

***********************************************************************************
//  STEP 2: RUN DO FILES FOR MAIN TEXT
***********************************************************************************

***  CONSTRUCT DATA:

do "DoFiles/ImportGoogleDataOnInventorGeographyFinal.do" // Creates necessary data files for analysis

***  MAIN TEXT:

do "DoFiles/WarsAndProthesisPatentsAnalysisOfCounts.do"

do "DoFiles/ConfederateAndBritishPatentAnalysis.do"

do "DoFiles/WarsAndProthesisPatentTrendsSynth.do"

do "DoFiles/WarsAndProsthesisTraitsEstimatesAndPValuesFullBoom.do"

***********************************************************************************
//  STEP 3: RUN DO FILES FOR APPENDIX MATERIAL
***********************************************************************************

*** APPENDIX MATERIAL (although much of appendix material is generated from above .do files):

do "DoFiles/WarsAndProthesisPatentsAnalysisOfCountsEventStudies.do" 

do "DoFiles/AnanalysisOfCitationWeightedCounts.do"

do "DoFiles/arm_vs_leg.do"

do "DoFiles/AnalysisOfHandCodedData1.do"

***********************************************************************************
//  STEP 4: RUN DO FILES AND PYTHON FILES FOR APPENDIX MATERIAL (WARNING, 10+ HOURS OF RUNTIME)
***********************************************************************************

// Appendix figure B.4 (WARNING: LONG RUN TIME); Need to run "compile_synth_perturbations.py" below to generate figure
foreach trait in simplicity{
forvalues y = 45/100{
forvalues x = 1/40{
do "DoFiles/CW_Synth_Perturbations.do" `x' `y' `trait'
}
}	
}
foreach trait in comfort{
forvalues y = 45/100{
forvalues x = 1/40{
do "DoFiles/WWI_Synth_Perturbations.do" `x' `y' `trait'
}
}	
}
// After installing the necessary packages in the .py files below , run the following .py files in your desired python 3 environment. If desired, to run within stata:

// Appendix Table C.2 and Table C.3
!python3 DoFiles/get_production_weights.py

// Appendix figure B.3 and Tables B.1 and B.2 (Results might not be identical due to random perturbations in the cross-validation procedure)
!python3 DoFiles/AppendixB.py

// Appendix figure B.4 (Results might not be identical due to random perturbations)
!python3 DoFiles/compile_synth_perturbations.py

***********************************************************************************
exit
